﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text;

namespace Vms.Business
{
    public class WriteFile
    {
        public void WriteStreamFile(string text)
        {
            string fileName = @"C:\chungtv\test\test.txt";
            if (!File.Exists(fileName))
            {
                FileStream fs = new FileStream(fileName, FileMode.Create);
                using (StreamWriter writer = new StreamWriter(fs))
                {
                    writer.WriteLine("\n" + text);
                }
                fs.Close();
            }
            else
            {
                FileStream fs = new FileStream(fileName, FileMode.Append);
                using (StreamWriter writer = new StreamWriter(fs))
                {
                    writer.WriteLine("\n" + text);
                }
                fs.Close();
            }
        }
        public void WriteError(string text)
        {
            string file = @"C:\chungtv\logError\Err.txt";
            if (!File.Exists(file))
            {
                FileStream fs = new FileStream(file, FileMode.Create);
                using (StreamWriter write = new StreamWriter(fs))
                {
                    write.WriteLine(DateTime.Now.ToShortTimeString() + ":" + text);
                }
                fs.Close();
            }
        }
    }
}
